Skip to content

fix(playground): read compile errors from their metadata, not their frame text - #206

Merged
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-marko-website-3w77hx
Jul 28, 2026
Merged

fix(playground): read compile errors from their metadata, not their frame text#206
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-marko-website-3w77hx

Conversation

@DylanPiercey

@DylanPiercey DylanPiercey commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The playground reconstructed every diagnostic by regex over the rendered code frame, even though the compiler hands it the same information structurally. CompileError carries loc and label; CompileErrors carries one child per diagnostic.

Parsing the text lost real information. Babel's caret row preserves the source's tabs, and MARKER_ROW's ( *) cannot match a tab, so a tab-indented template rendered a build failure with no message, no caret, and a raw | \t\t^ … blob in the details block with its markdown links unrendered. An aggregate also collapsed into one card.

Now the error is read from its own properties, and the frame is cut from the workspace source instead of being parsed back out of a string — so tabs, CRLF, wide characters and a | inside the source all stop mattering. Tabs are expanded so the caret row and the code row share one grid.

loc is normalized from both the nested Marko/Babel shape ({start,end}) and Rollup's flat one ({line,column}), so an error from a .js or .css file in the playground gets the same rendering rather than falling back to plain text. The frame parser is kept as the fallback for producers that carry no position at all, such as runtime errors.

CompileError does not expose its filename — the copy inside the message is relativized against a cwd the browser does not have (at ../../../../../../tags/index.marko:2:1) — so the compile call site records it. Exposing filename upstream would remove that step; worth a small follow-up in marko.

Verified end to end against the real compiler:

input before after
\t\t<log/> message and caret dropped Line has extra indentation at the beginning, caret under <log/>
unclosed <span> correct ^^^^^^ under <span>
two content= errors one card two cards, each with its own caret

Testing

Adds vitest, wired into CI ahead of the build since these are pure unit tests.

@marko/vite moves 6.1.8 → 6.1.9 (lockfile only; it is a transitive dep of @marko/run, whose ^6.0.3 range already allowed it). 6.1.8 threw Cannot read properties of undefined (reading 'environment') whenever vitest resolved a config without a test section, which marko-js/vite#302 fixed.

With that in, running against the site's own vite.config.ts works — so the separate vitest.config.ts is now a choice rather than a workaround, and it is kept on measured grounds:

config wall clock vitest duration
dedicated vitest.config.ts 0.56 s 291 ms
site vite.config.ts 1.90 s 320 ms

Resolving the site plugin chain roughly triples startup for tests that need none of it.

@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 14bde97

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22415384-858a-4b12-b716-90b77f60809a

📥 Commits

Reviewing files that changed from the base of the PR and between 298ea59 and 14bde97.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by **
📒 Files selected for processing (8)
  • .github/workflows/ci.yml
  • package.json
  • src/routes/playground/tags/playground/tags/result/result.marko
  • src/routes/playground/tags/playground/tags/result/tags/error-output/error-output.marko
  • src/util/compile-error.test.ts
  • src/util/compile-error.ts
  • src/util/workspace/marko-plugin.ts
  • vitest.config.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dpiercey-ws-marko-website-3w77hx

Comment @coderabbitai help to get the list of available commands.

@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-website-3w77hx branch from 96351ed to 1f32fac Compare July 28, 2026 18:29
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

PR Preview Deployed (removed)

Your changes are live at markojs.com/previews/pr-206.

commit 14bde97

@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-website-3w77hx branch from 1f32fac to abee2eb Compare July 28, 2026 18:35
…rame text

`CompileError` carries `loc` and `label`, and `CompileErrors` carries one
child per diagnostic, but the playground reconstructed all of it by regex
over the rendered frame. That lost real information: the caret row keeps the
source's tabs, and `( *)` could not match them, so a tab-indented template
rendered a build failure with no message, no caret, and a raw `| \t\t^ ...`
blob. An aggregate also rendered as a single card.

Errors are now normalized from their own properties, and the frame is cut
from the workspace source rather than parsed back out of a string, so tabs,
CRLF, wide characters and a `|` inside the source stop mattering. `loc` is
read in both the nested Marko/Babel shape and Rollup's flat one, so an error
from a `.js` or `.css` file in the playground gets the same treatment. The
frame parser stays as the fallback for producers that carry no position.

`CompileError` does not expose its filename -- the copy in the message is
relativized against a cwd the playground does not have -- so the compile
call site records it.

Adds vitest and covers the metadata path, the tab case, aggregates, a
Rollup-shaped error, and both fallbacks. Its config is separate from
vite.config.ts because resolving the site's plugin chain roughly triples
startup for tests that need none of it; @marko/vite moves to 6.1.9, which
no longer crashes when vitest resolves a config without a `test` section.
@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-website-3w77hx branch from abee2eb to 14bde97 Compare July 28, 2026 19:06
@DylanPiercey
DylanPiercey merged commit b42b344 into main Jul 28, 2026
4 checks passed
@DylanPiercey
DylanPiercey deleted the dpiercey-ws-marko-website-3w77hx branch July 28, 2026 19:13
@github-project-automation github-project-automation Bot moved this to Todo in Roadmap Jul 31, 2026
@DylanPiercey DylanPiercey moved this from Todo to Done in Roadmap Jul 31, 2026
@DylanPiercey DylanPiercey self-assigned this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant